/**
 * Created by Administrator on 2017/3/2 0002.
 */
var Page3={
    create:function () {
       var loop_first;

    var page={};
        page.ui=new PIXI.DisplayObjectContainer();
        var bg=Easy.CreateSprite('assets/images/p1_bg.png',0,0,0,0,1);
        page.ui.addChild(bg);

        var d0=Easy.CreateSprite('assets/images/p1_d0.png',-266,-32,0,0,0.5);
        page.ui.addChild(d0);
        TweenMax.to(d0,10,{x:-210,yoyo:true,repeat:-1,repeatDelay:1,ease:Linear.easeNone});
        TweenMax.to(d0,2,{alpha:1,yoyo:true,repeat:-1,repeatDelay:0.5,ease:Linear.easeNone});


        var tip=Easy.CreateSprite('assets/images/tip.png',367,1076,0.5,0.5,1);
        page.ui.addChild(tip);
        TweenMax.to(tip,0.7,{y:1100,yoyo:true,repeat:-1,ease:Cubic.easeInOut});

        var i0=Easy.CreateSprite('assets/images/p3_i0.png',376,619,0.5,0.5,0);
        var i1=Easy.CreateSprite('assets/images/p3_i1.png',376,619,0.5,0.5,0);
        var i2=Easy.CreateSprite('assets/images/p3_i2.png',376,619,0.5,0.5,0);
        var i3=Easy.CreateSprite('assets/images/p3_i3.png',376,619,0.5,0.5,0);

        var t0=Easy.CreateSprite('assets/images/p3_t0.png',376,128,0.5,0.5,0);
        var t1=Easy.CreateSprite('assets/images/p3_t1.png',376,185,0.5,0.5,0);
        var t2=Easy.CreateSprite('assets/images/p3_t2.png',376,250,0.5,0.5,0);
        var t3=Easy.CreateSprite('assets/images/p3_t3.png',376,290,0.5,0.5,0);
        var t4=Easy.CreateSprite('assets/images/p3_t4.png',376,349,0.5,0.5,0);
        var t5=Easy.CreateSprite('assets/images/p3_t5.png',376,995,0.5,0.5,0);

        var light0=Easy.CreateSprite('assets/images/light0.png',304,263,0.5,0.5,1);
        light0.scale.x=light0.scale.y=0;
        light0.blendMode=PIXI.BLEND_MODES.ADD;

        var light1=Easy.CreateSprite('assets/images/light1.png',492,155,0.5,0.5,0.5);
        light1.scale.x=light1.scale.y=0;
        light1.blendMode=PIXI.BLEND_MODES.ADD;

        page.ui.addChild(i0);
        page.ui.addChild(i1);
        page.ui.addChild(i2);
        page.ui.addChild(i3);

        page.ui.addChild(t0);
        page.ui.addChild(t1);
        page.ui.addChild(t2);
        page.ui.addChild(t3);
        page.ui.addChild(t4);
        page.ui.addChild(t5);

        page.ui.addChild(light0);
        page.ui.addChild(light1);

        function loop(bool) {
            var firstDelay=0.5;
            if(bool)
            {
                i0.alpha=0;
                i1.alpha=0;
                i2.alpha=0;
                i3.alpha=0;
                firstDelay=1
            }
            else
            {
                firstDelay=1
            }

            TweenMax.to(i0,1.5,{delay:firstDelay,alpha:1,onComplete:function () {
                i3.alpha=0;
                page.ui.addChild(i1);
                TweenMax.to(i1,1.5,{delay:1,alpha:1,onComplete:function () {
                    i0.alpha=0;
                    page.ui.addChild(i2);
                    TweenMax.to(i2,1.5,{delay:1,alpha:1,onComplete:function () {
                        i1.alpha=0;
                        page.ui.addChild(i3);
                        TweenMax.to(i3,1.5,{delay:1,alpha:1,onComplete:function () {
                            i2.alpha=0;
                            page.ui.addChild(i0);
                            loop(false);
                        }})
                    }})
                }})
            }});
        }

        page.In=function () {
            console.log('in');

            loop(true);

            t0.scale.x=t0.scale.y=0;
            t1.scale.x=t1.scale.y=0;
            t2.scale.x=t2.scale.y=0;
            t3.scale.x=t3.scale.y=0;
            t4.scale.x=t4.scale.y=0;
            t5.scale.x=t5.scale.y=0;
            TweenMax.to(t0.scale,0.9,{delay:0.2*2,x:1,y:1,ease:Back.easeOut});
            TweenMax.to(t0,0.9,{delay:0.2*2,alpha:1,ease:Back.easeOut});
            TweenMax.to(t1.scale,0.9,{delay:0.2*3,x:1,y:1,ease:Back.easeOut});
            TweenMax.to(t1,0.9,{delay:0.2*3,alpha:1,ease:Back.easeOut});
            TweenMax.to(t2.scale,0.9,{delay:0.2*4,x:1,y:1,ease:Back.easeOut});
            TweenMax.to(t2,0.9,{delay:0.2*4,alpha:1,ease:Back.easeOut});
            TweenMax.to(t3.scale,0.9,{delay:0.2*5,x:1,y:1,ease:Back.easeOut});
            TweenMax.to(t3,0.9,{delay:0.2*5,alpha:1,ease:Back.easeOut});
            TweenMax.to(t4.scale,0.9,{delay:0.2*6,x:1,y:1,ease:Back.easeOut});
            TweenMax.to(t4,0.9,{delay:0.2*6,alpha:1,ease:Back.easeOut});
            TweenMax.to(t5.scale,0.9,{delay:0.2*7,x:1,y:1,ease:Back.easeOut});
            TweenMax.to(t5,0.9,{delay:0.2*7,alpha:1,ease:Back.easeOut});


            light1.scale.x=light1.scale.y=0;
            TweenMax.to(light1.scale,0.5,{delay:1.5,x:1,y:1,ease:Back.easeOut});
            light0.scale.x=light0.scale.y=0;
            TweenMax.to(light0.scale,0.5,{delay:1.7,x:1,y:1,ease:Back.easeOut});

            TweenMax.to(light0,3,{x:463,yoyo:true,repeat:-1,repeatDelay:1,ease:Linear.easeNone});
            TweenMax.to(light1,1,{alpha:1,yoyo:true,repeat:-1,repeatDelay:0.5,ease:Cubic.easeInOut});
        }
        page.Out=function () {
            console.log('out');
            TweenMax.killTweensOf(i0);
            TweenMax.killTweensOf(i1);
            TweenMax.killTweensOf(i2);
            TweenMax.killTweensOf(i3);
            TweenMax.killTweensOf(t0);
            TweenMax.killTweensOf(t1);
            TweenMax.killTweensOf(t2);
            TweenMax.killTweensOf(t3);
            TweenMax.killTweensOf(t4);
            TweenMax.killTweensOf(t5);
            TweenMax.killTweensOf(light0);
            TweenMax.killTweensOf(light1);
            setTimeout(function () {
                i0.alpha=0;
                i1.alpha=0;
                i2.alpha=0;
                i3.alpha=0;
                t0.alpha=0;
                t1.alpha=0;
                t2.alpha=0;
                t3.alpha=0;
                t4.alpha=0;
                t5.alpha=0;
                light0.scale.x=light0.scale.y=0;
                light1.scale.x=light1.scale.y=0;
            })

        }

       
    return page;
    }
}